(in-package #:experiment)

(defclass crosshair (state)
  ((duration :initarg :duration :accessor crosshair-duration)))

(defmethod gwee:draw-view ((view crosshair))
  (gwee:draw-rectangle view
                       (- (u:half (gwee:view-width view)) 10) (- (u:half (gwee:view-height view)) 2)
                       20 4
                       :filled t)
  (gwee:draw-rectangle view
                       (- (u:half (gwee:view-width view)) 2) (- (u:half (gwee:view-height view)) 10)
                       4 20
                       :filled t))

(defmethod state-init (experiment (state crosshair))
  (log experiment 'start)
  (start-timer (crosshair-duration state)))

(defmethod state-dump append (experiment (state crosshair))
  `(:duration ,(crosshair-duration state)))

(define-action onward ((state crosshair)
                       (timeout))
  (state-onward *experiment* state))

(defmethod exp:state-list-actions append (experiment (state crosshair))
  (exp::default-list-event-translations state))
